<!DOCTYPE html>
<html>
{include file="public/head"}

<body>
    {include file="contest/contest-nav"}
    </div>
    </div>
    <div class="layui-container fly-marginTop" style=''>
        
    </div>
    </div>
{include file="public/foot"}
</body>
<script>    
    layui.use(['layer'],function(){
        var layer=layui.layer;
        var content=["<div class=\"fly-panel fly-panel-user \" style=\"padding-left:20px;padding-right: 20px;\">",
"    <div class=\"layui-tab layui-tab-brief\" lay-filter=\"user\">",
"        <ul class=\"layui-tab-title\">",
"            <li class=\"layui-this\">密码验证</li>",
"        </ul>",
"        <div class=\"layui-form layui-tab-content\" id=\"LAY_ucm\" style=\"padding: 20px 0;\">",
"            <div class=\"layui-tab-item layui-show\">",
"                <div class=\"layui-form layui-form-pane\">",
"                    <form method=\"post\" action=\"{:url('contest/subpasswd')}\" id=\"myform\">",
"                        <div class=\"layui-form-item\">",
"                            <label for=\"L_pass\" class=\"layui-form-label\">密码</label>",
"                            <div class=\"layui-input-inline\">",
"                                <input type=\"text\" id=\"contest_password\" name=\"contest_password\"  autocomplete=\"off\" class=\"layui-input\">",
"                            </div>",
"                        </div>",
"                        <div class=\"layui-form-item\" style=\"text-align: right;padding-right: 10px;\">",
"                            <button class=\"layui-btn\" lay-filter=\"submit\" lay-submit>提交</button>",
"                        </div>",
"                    </form>",
"                </div>",
"            </div>",
"        </div>",
"    </div>",
"</div>"].join("");
        layer.open({
           type:1,
           title:'密码输入',
           closeBtn: 1,
           shadeClose: false,
           content: content,
           resize:false,
           cancel:function(){
               location.href='{:url("web/Contest/index")}';
           }
        });
    });
layui.use(['form', 'jquery', 'layer'], function() {
    var form = layui.form;
    var $ = layui.jquery;
    var layer = layui.layer;
    form.on('submit(submit)', function(data) {
        // layer.msg(JSON.stringify(data.field));
        // console.log(data.field); //当前容器的全部表单字段，名值对形式：{name: value}
        $.ajax({
            url: "{:url('contest/subpasswd',['cid'=> $list[0]['contest_id']])}",
            type: 'post',
            data: data.field,
            dataType: "JSON",
            success: function(res) {
                // console.log("result=" + res.url);
                if(res.result==-1) {
                    layer.msg(res.msg);
                }
                else if (res.result == 1) {
                    window.location.href=res.url;
                } else {
                    layer.msg('当前密码输入错误');
                    $(".layui-input").blur();
                }
            },
            error: function() {
                layer.msg('页面进入后台失败');
            }
        });
        return false;
    });
});
</script>

</html>